package org.frame.factory;

import java.io.InputStream;

public class FactoryGet {
    private  static IFactory factory;
    private  static  InputStream input;
//    私有化，只允许本类调用
    private static void createFactory(InputStream inputStream){
        factory = new FactoryBuilderDirector(inputStream).build();
    }
    public static void loadResource(String path){
        input = FactoryGet.class.getResourceAsStream(path);
        if(factory !=null){
            factory.loadInf(input);
        }
    }
     public static IFactory getFactory(){
         if(factory==null){
             synchronized (FactoryGet.class){
                 if(factory ==null){
                     createFactory(input);
                 }
             }
         }
         return factory;
     }
}
